<template>
    <div class="mui-numbox" data-numbox-min='1' :data-numbox-max='max'  data-numbox-step='1'>
		<button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
		<input id="test" class="mui-input-numbox" type="number" value="1" @change="countChanged" ref="numbox" />
		<button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
	</div>
</template>


<script>
import mui from '../../lib/mui/js/mui.min.js';
export default {
    // 初始化数字选择框
    mounted(){
        mui('.mui-number').numbox();
        console.log(this.max)
    },
    // 分析。子组件传值的时机：input的数值改变
    methods:{
        countChanged(){
            // 每当文本框数据被修改
            console.log(this.$refs.numbox.value);
            this.$emit('getCount',parseInt(this.$refs.numbox.value));
        }
    },
    props:["max"],
    watch:{
        // 属性监听
        'max':function(newVal,oldVal){
            mui('.mui-number').numbox().setOption('max',newVal);
        }
    }
    
}
</script>


<style lang="less" scoped>

</style>


